from coin.exchange.base.kr_rest.product import NativeProduct, NormProduct
from coin.exchange.korbit_v1.kr_rest.currency import KorbitCurrency
from coin.exchange.korbit_v1.kr_rest.constants import (base_currency_list, quote_currency_list)


class KorbitProduct(NativeProduct):
  _exchange = "Korbit"
  NativeCurrencyType = KorbitCurrency

  def __init__(self, base, quote):
    assert base != quote, (base, quote)
    assert quote.currency in quote_currency_list, quote
    native_symbol = "%s_%s" % (base.native_symbol, quote.native_symbol)
    super().__init__(base, quote, native_symbol)

  @classmethod
  def FromStrNativeProductImpl(cls, product, current_datetime):
    assert isinstance(product, str), type(product)
    base, quote = product.split('_')
    base = KorbitCurrency.FromStrNativeCurrency(base)
    quote = KorbitCurrency.FromStrNativeCurrency(quote)
    return KorbitProduct(base, quote)
